<?php
/* 
  $Id: cms_content.php,v 1.1 2008/03/05 15:48:49 tiger Exp $ 
 
  Open Source E-Commerce Solutions 
  http://www.oscommerce.com 
 
  Copyright (c) 2002 osCommerce.com 
 
  Released under the GNU General Public License 
*/

  require('includes/application_top.php');

// print_r($HTTP_POST_VARS);

  $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

if((($action == 'update')||($action == 'insert'))&&(isset($HTTP_POST_VARS['edit_x'])||isset($HTTP_POST_VARS['edit_y']))) $action = 'edit';

  if (tep_not_null($action)) {
    switch ($action) {
      // [BOF] v0.2 20080305 itx freddy
      case 'setflag':
        if ( ($HTTP_GET_VARS['flag'] == '0') || ($HTTP_GET_VARS['flag'] == '1') ) {
          if (isset($HTTP_GET_VARS['cID'])) {
            tep_cms_set_content_status($HTTP_GET_VARS['cID'], $HTTP_GET_VARS['flag']);
          }
        }
	tep_redirect(tep_href_link(FILENAME_CMS_CONTENT, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $HTTP_GET_VARS['cID']));
        break;
      case 'insert':
      case 'update':

	$content_name = tep_db_prepare_input($HTTP_POST_VARS['content_name']);
	$content_text = tep_db_prepare_input($HTTP_POST_VARS['content_text']);
	$content_title = tep_db_prepare_input($HTTP_POST_VARS['content_title']); // itx freddy 20080305 added content_title

	$sql_data_array = array('content_name' => tep_db_prepare_input($content_name),
                                'content_status' => tep_db_prepare_input($HTTP_POST_VARS['content_status'])); // itx freddy 20080305 added content_status

        if ($action == 'insert') {
		$insert_sql_data = array('date_added' => 'now()');
		$sql_data_array = array_merge($sql_data_array, $insert_sql_data);
		tep_db_perform(TABLE_CONTENT, $sql_data_array);
		$content_id = tep_db_insert_id();
        } elseif ($action == 'update') {
	        $update_sql_data = array('last_modified' => 'now()');
                $sql_data_array = array_merge($sql_data_array, $update_sql_data);
		$content_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);
		tep_db_perform(TABLE_CONTENT, $sql_data_array, 'update', "content_id = '" . (int)$content_id . "'");
			
        }

        $languages = tep_get_languages();
        for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
          $language_id = $languages[$i]['id'];
	  $sql_data_array = array('content_text' => tep_db_prepare_input($content_text[$i]),
                                 'content_title' => tep_db_prepare_input($content_title[$i])); // itx freddy 20080305 added content_title
          if ($action == 'insert') {
            $insert_sql_data = array('content_id' => $content_id, 'language_id' => $language_id);
            $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
            tep_db_perform(TABLE_CONTENT_DESCRIPTION, $sql_data_array);
          } elseif ($action == 'update') {
            tep_db_perform(TABLE_CONTENT_DESCRIPTION, $sql_data_array, 'update', "content_id = '" . (int)$content_id . "' and language_id = '" . (int)$language_id . "'");
          }
        }

	tep_redirect(tep_href_link(FILENAME_CMS_CONTENT, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $content_id));
        break;
      // [EOF] v0.2 20080305 itx freddy
      case 'deleteconfirm':
        $content_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);

        tep_db_query("delete from " . TABLE_CONTENT . " where content_id = '" . (int)$content_id . "'");
        tep_db_query("delete from " . TABLE_CONTENT_DESCRIPTION . " where content_id = '" . (int)$content_id . "'");

        tep_redirect(tep_href_link(FILENAME_CMS_CONTENT, 'page=' . $HTTP_GET_VARS['page']));
        break;
    }
  }
  
    require(DIR_WS_INCLUDES . 'template_top.php');
?>

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
  <tr>

<!-- body_text //-->
    <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
            <td class="pageHeading" align="right"></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
<?php
  if (($action == 'new')||($action == 'edit')) {

$cID = tep_db_prepare_input($HTTP_GET_VARS['cID']); // 20080305 bug fix, the $cID was undefined so the name was not being shown
$content_text = array();
$content_title = array(); // 20080305 itx freddy added the title
$languages = tep_get_languages();

if($action == 'edit'){
	if (isset($HTTP_POST_VARS['edit_x']) || isset($HTTP_POST_VARS['edit_y'])){
		$cInfo_array = array('content_name' => tep_db_prepare_input($HTTP_POST_VARS['content_name']),  'date_added' => '', 'last_modified' => '', 'content_status' => '0');
		for ($i=0, $n=sizeof($languages); $i<$n; $i++) $content_text[$i] = $HTTP_POST_VARS['content_text'][$i];
	}else{
		$content_query = tep_db_query("select content_id, content_name, date_added, last_modified, content_status from " . TABLE_CONTENT . " where content_id = '" . (int)$cID . "'");
		$cInfo_array = tep_db_fetch_array($content_query);
		// $cInfo_array = $content;
		for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
			$language_id = $languages[$i]['id'];
			$cID = tep_db_prepare_input($HTTP_GET_VARS['cID']);
			$content_query = tep_db_query("select cd.content_text, cd.content_title from " . TABLE_CONTENT . " c, " . TABLE_CONTENT_DESCRIPTION . " cd where c.content_id = '" . (int)$cID . "' and c.content_id = cd.content_id and language_id='" . $language_id . "'");
			$content = tep_db_fetch_array($content_query);
			$content_text[$i] = $content['content_text'];
			$content_title[$i] = $content['content_title'];
		}
	}
} elseif($action == 'new') {
	$cInfo_array = array('content_name' => tep_db_prepare_input($HTTP_POST_VARS['content_name']),  'date_added' => '', 'last_modified' => '', 'content_status' => '1');
	for ($i=0, $n=sizeof($languages); $i<$n; $i++) { // itx freddy 20080305 added the title
          $content_text[$i] = $HTTP_POST_VARS['content_text'][$i];
          $content_title[$i] = $HTTP_POST_VARS['content_title'][$i];
	}
}

$cInfo = new objectInfo($cInfo_array);

?>
      <tr><?php echo tep_draw_form('review', FILENAME_CMS_CONTENT, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $HTTP_GET_VARS['cID'] . '&action=preview'); ?>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
		<td class="main" valign="top"><b><?php echo ENTRY_CONTENT . tep_draw_input_field('content_name', $cInfo->content_name); ?></b></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>

      <?php // [BOF] 20080305 itx freddy added the status field 
        if (!isset($cInfo->content_status)) $cInfo->content_status = '1';
        switch ($cInfo->content_status) {
          case '0': $enabled_status = false; $disabled_status = true; break;
          case '1':
          default:  $enabled_status = true;  $disabled_status = false;
        }
      ?>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
		<td class="main"><?php echo TEXT_CONTENT_STATUS; ?></td>
                <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_radio_field('content_status', '1', $enabled_status) . '&nbsp;' . TEXT_CONTENT_ENABLED . '&nbsp;' . tep_draw_radio_field('content_status', '0', $disabled_status) . '&nbsp;' . TEXT_CONTENT_DISABLED; ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
<?php      // [EOF] 20080305 status field 
    $languages = tep_get_languages();
    for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
	    // 20080305 itx freddy added the title to the languages loop
?>
      <tr>
        <td><table witdh="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td  valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?></td>
            <td width=10>&nbsp</td>
            <td class="main" valign="top"><?php echo '<b>' . ENTRY_TITLE . '</b>' . tep_draw_input_field('content_title[' . $i . ']', $content_title[$i], 'size=70', true); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
      <tr>
        <td><table witdh="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td  valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?></td>
            <td width=10>&nbsp</td>
            <td class="main" valign="top"><?php echo tep_draw_textarea_field('content_text[' . $i . ']', 'soft', '100', '25', $content_text[$i]); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
<?php
    }
?>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
      <tr>
        <td align="right" class="main">
		<?php echo tep_draw_hidden_field('content_id', $cInfo->content_id) . tep_draw_hidden_field('date_added', $cInfo->date_added) . tep_image_submit('button_preview.gif', IMAGE_PREVIEW) . ' <a href="' . tep_href_link(FILENAME_CMS_CONTENT, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $HTTP_GET_VARS['cID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?>
       </td>
      </form></tr>
<?php
  } elseif ($action == 'preview') {
    if (tep_not_null($HTTP_POST_VARS)) {
      $cInfo = new objectInfo($HTTP_POST_VARS);
    } else {
      $cID = tep_db_prepare_input($HTTP_GET_VARS['cID']);

      $content_query = tep_db_query("select c.content_id, c.content_name, c.date_added, c.last_modified, c.content_status from " . TABLE_CONTENT . " c where c.content_id = '" . (int)$cID . "'"); // 20080305 itx added status
      $content = tep_db_fetch_array($content_query);

      $contents=array();
      $titles=array();
      $languages = tep_get_languages();
      for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
      		$content_desc_query = tep_db_query("select cd.content_text, cd.content_title from " . TABLE_CONTENT . " c, " . TABLE_CONTENT_DESCRIPTION . " cd where c.content_id = '" . (int)$cID . "' and c.content_id = cd.content_id and cd.language_id='" . $languages[$i]['id'] . "'");
      		$content_desc = tep_db_fetch_array($content_desc_query);
      		$contents[$i] = $content_desc['content_text'];
      		$titles[$i] = $content_desc['content_title'];
      }

      $content['content_text'] = $contents;
      $content['content_title'] = $titles;
      $cInfo_array = array_merge($content);
      $cInfo = new objectInfo($cInfo_array);

    }

?>
      <tr><?php 

if(empty($cInfo->content_id))
	echo tep_draw_form('insert', FILENAME_CMS_CONTENT, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $HTTP_GET_VARS['cID'] . '&action=insert', 'post', 'enctype="multipart/form-data"');
else
	echo tep_draw_form('update', FILENAME_CMS_CONTENT, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $HTTP_GET_VARS['cID'] . '&action=update', 'post', 'enctype="multipart/form-data"');

?>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
		<td class="main" valign="top">
		<b><?php echo ENTRY_CONTENT; ?></b>
		<?php echo $cInfo->content_name; ?><br><b>
		</td>
          </tr>
        </table>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
      <?php // [BOF] 20080305 itx freddy added the status field 
        if (!isset($cInfo->content_status)) $cInfo->content_status = '1';
      ?>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
	    <td class="main" valign="top">
		<b><?php echo TEXT_CONTENT_STATUS; ?></b>
		<?php echo '&nbsp;' . ($cInfo->content_status == '1'? TEXT_CONTENT_ENABLED : TEXT_CONTENT_DISABLED);?>
            </td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
<?php      // [EOF] 20080305 status field 
    $languages = tep_get_languages();
    for ($i=0, $n=sizeof($languages); $i<$n; $i++) { // 20080305 itx freddy added the title to the language loop
?>
      <tr>
        <td><table witdh="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td  class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?></td>
            <td width=10>&nbsp</td>
            <td class="main" valign="top"><?php echo '<b>' . ENTRY_TITLE . '</b>' . '&nbsp;' . $cInfo->content_title[$i]; ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
      <tr>
        <td><table witdh="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td  class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?></td>
            <td width=10>&nbsp</td>
            <td class="main" valign="top"><?php echo tep_cms_image_replace(nl2br($cInfo->content_text[$i])); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
<?php
    }
?>

<?php
    if (tep_not_null($HTTP_POST_VARS)) {
/* Re-Post all POST'ed variables */
      reset($HTTP_POST_VARS);
      while(list($key, $value) = each($HTTP_POST_VARS)) {
		if($key == 'content_text'){
			while(list($k, $v) = each($value)) echo tep_draw_hidden_field('content_text[' . $k . ']', $v);
		} elseif($key == 'content_title'){ // 20080305 added the title
			while(list($k, $v) = each($value)) echo tep_draw_hidden_field('content_title[' . $k . ']', $v);
		}else{
              		echo tep_draw_hidden_field($key, $value);
		}
      }

?>
      <tr>
        <td align="right" class="smallText">
<?php 

if(empty($cInfo->content_id)) {
	$button = tep_image_submit('button_insert.gif', IMAGE_INSERT);
} else {
	$button = tep_image_submit('button_update.gif', IMAGE_UPDATE);
}

$back_button = tep_image_submit('button_back.gif', IMAGE_BACK, 'name="edit"');

//echo tep_draw_hidden_field('cID', $HTTP_GET_VARS['page']);

//echo '<a href="' . tep_href_link(FILENAME_CMS_CONTENT, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->content_id . $back_action) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a> ' 
echo $back_button . $button . ' <a href="' . tep_href_link(FILENAME_CMS_CONTENT, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $HTTP_GET_VARS['cID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>';

?>
</td>
      </form></tr>
<?php
    } else {
      if (isset($HTTP_GET_VARS['origin'])) {
        $back_url = $HTTP_GET_VARS['origin'];
        $back_url_params = '';
      } else {
        $back_url = FILENAME_CMS_CONTENT;
        $back_url_params = 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->content_id;
      }
?>
      <tr>
        <td align="right"><?php echo '<a href="' . tep_href_link($back_url, $back_url_params, 'NONSSL') . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
      </tr>
<?php
    }
  } else {
?>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr class="dataTableHeadingRow">
                <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_LISTINGS; ?></td>
                <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_DATE_ADDED; ?></td>
                <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_STATUS; ?></td>
                <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
              </tr>
<?php
    $content_query_raw = "select content_id, content_name, date_added, last_modified, content_status from " . TABLE_CONTENT . " order by date_added DESC";
    $content_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $content_query_raw, $content_query_numrows);
    $content_query = tep_db_query($content_query_raw);
    while ($content = tep_db_fetch_array($content_query)) {
      if ((!isset($HTTP_GET_VARS['cID']) || (isset($HTTP_GET_VARS['cID']) && ($HTTP_GET_VARS['cID'] == $content['content_id']))) && !isset($cInfo)) {

	$content_text_size = array();
        $languages = tep_get_languages();
        for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
              $content_text_query = tep_db_query("select length(cd.content_text) as content_text_size from   " . TABLE_CONTENT . " c,  " . TABLE_CONTENT_DESCRIPTION . " cd where c.content_id = '" . (int)$content['content_id'] . "' and c.content_id = cd.content_id and cd.language_id='" . $languages[$i]['id']. "'");
              $content_text = tep_db_fetch_array($content_text_query);
              if($content_text['content_text_size']=="") $content_text['content_text_size'] = '0';
              $content_text_size[$i] = $content_text['content_text_size'];
        }

	$content['content_text_size'] = $content_text_size;
        $cInfo_array = array_merge($content);
        $cInfo = new objectInfo($cInfo_array);
      }

      if (isset($cInfo) && is_object($cInfo) && ($content['content_id'] == $cInfo->content_id) ) {
        echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CMS_CONTENT, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $content['content_id'] . '&action=preview') . '\'">' . "\n";
      } else {
        echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CMS_CONTENT, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $content['content_id']) . '\'">' . "\n";
      }
?>
                <td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_CMS_CONTENT, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $content['content_id'] . '&action=preview') . '">' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . '</a>&nbsp;' . $content['content_name']; ?></td>
                <td class="dataTableContent" align="right"><?php echo tep_date_short($content['date_added']); ?></td>
                <td class="dataTableContent" align="center">
<?php
      if ($content['content_status'] == '1') {
        echo tep_image(DIR_WS_IMAGES . 'icon_status_green.gif', IMAGE_ICON_STATUS_GREEN, 10, 10) . '&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_CMS_CONTENT, 'action=setflag&flag=0&cID=' . $content['content_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_red_light.gif', IMAGE_ICON_STATUS_RED_LIGHT, 10, 10) . '</a>';
      } else {
        echo '<a href="' . tep_href_link(FILENAME_CMS_CONTENT, 'action=setflag&flag=1&cID=' . $content['content_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_green_light.gif', IMAGE_ICON_STATUS_GREEN_LIGHT, 10, 10) . '</a>&nbsp;&nbsp;' . tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', IMAGE_ICON_STATUS_RED, 10, 10);
      }
?></td>
                <td class="dataTableContent" align="right"><?php if ( (is_object($cInfo)) && ($content['content_id'] == $cInfo->content_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '<a href="' . tep_href_link(FILENAME_CMS_CONTENT, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $content['content_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
              </tr>
<?php
    }
?>
              <tr>
                <td colspan="4"><table border="0" width="100%" cellspacing="0" cellpadding="2">
                  <tr>
                    <td class="smallText" valign="top"><?php echo $content_split->display_count($content_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_CONTENT); ?></td>
                    <td class="smallText" align="right"><?php echo $content_split->display_links($content_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page']); ?></td>
                  </tr>
                </table></td>
              </tr>

<?php
  if (empty($action)) {
?>
              <tr>
                <td align="right" colspan="2" class="smallText"><?php echo '<a href="' . tep_href_link(FILENAME_CMS_CONTENT, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->content_id . '&action=new') . '">' . tep_image_button('button_insert.gif', IMAGE_INSERT) . '</a>'; ?></td>
              </tr>
<?php
  }
?>

            </table></td>
<?php
    $heading = array();
    $contents = array();

    switch ($action) {
      case 'delete':
        $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_CONTENT . '</b>');

        $contents = array('form' => tep_draw_form('content', FILENAME_CMS_CONTENT, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->content_id . '&action=deleteconfirm'));
        $contents[] = array('text' => TEXT_INFO_DELETE_CONTENT_INTRO);
        $contents[] = array('text' => '<br><b>' . $cInfo->listings_name . '</b>');
        $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_CMS_CONTENT, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->content_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
        break;
      default:
      if (isset($cInfo) && is_object($cInfo)) {
        $heading[] = array('text' => '<b>' . $cInfo->content_name . '</b>');

        $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_CMS_CONTENT, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->content_id . '&action=edit') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_CMS_CONTENT, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->content_id . '&action=delete') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a>');
        $contents[] = array('text' => '<br>' . TEXT_INFO_DATE_ADDED . ' ' . tep_date_short($cInfo->date_added));
        if (tep_not_null($cInfo->last_modified)) $contents[] = array('text' => TEXT_INFO_LAST_MODIFIED . ' ' . tep_date_short($cInfo->last_modified));
        $languages = tep_get_languages();
        for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
         	$contents[] = array('text' => '<br>' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . TEXT_INFO_CONTENT_SIZE . ' ' . $cInfo->content_text_size[$i] . ' bytes');
	}
      }
        break;
    }

    if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
      echo '            <td width="25%" valign="top">' . "\n";

      $box = new box;
      echo $box->infoBox($heading, $contents);

      echo '            </td>' . "\n";
    }
?>
          </tr>
        </table></td>
      </tr>
<?php
  }
?>
    </table></td>
<!-- body_text_eof //-->
  </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
